﻿using System.ComponentModel.DataAnnotations;
using VisionCloud.Core.Model.Enums;

namespace VisionCloud.Domain.DtoModel.Applet.RequestDto
{
    /// <summary>
    /// 微信小程序质量分析dto
    /// </summary>
    public class WxQualityAnalysisDto
    {
        /// <summary>
        /// 项目Id
        /// </summary>
        [Required]
        public string ProjectId { get; set; }

        /// <summary>
        /// 项目名
        /// </summary>
        public string ProjectName { get; set; }

        /// <summary>
        /// 工程阶段
        /// </summary>
        [Required]
        public string ProjectStage { get; set; }

        /// <summary>
        /// 楼栋名
        /// </summary>
        [Required]
        public string BuildingName { get; set; }

        /// <summary>
        /// 楼层名
        /// </summary>
        public string FloorName { get; set; } = string.Empty;

        /// <summary>
        /// 任务类型：自检/巡检
        /// </summary>
        [Required]
        public TaskTypeEnum TaskType { get; set; }

        /// <summary>
        /// 任务属性：初测/复测/其他
        /// </summary>
        [Required]
        public TaskPropertyEnum TaskProperty { get; set; }

        /// <summary>
        /// 项目编号
        /// </summary>
        public string ProjectNo { get; set; }

        public static string TransferTaskPropertyWhereSql(TaskPropertyEnum property, string tableAlias = "")
        {
            string dotStr = string.Empty;
            if (!string.IsNullOrWhiteSpace(tableAlias) && !tableAlias.EndsWith("."))
            {
                dotStr = ".";
            }

            switch (property)
            {
                case TaskPropertyEnum.初测:
                    return $@" AND ({tableAlias}{dotStr}""TaskProperty"" = '初测')";

                case TaskPropertyEnum.复测:
                    return $@" AND ({tableAlias}{dotStr}""TaskProperty"" = '复测')";

                case TaskPropertyEnum.其他:
                    return $@" AND ({tableAlias}{dotStr}""TaskProperty"" != '初测' AND {tableAlias}{dotStr}""TaskProperty"" != '复测')";

                default:
                    return string.Empty;
            }
        }
    }
}